package net.coding.li709.materialrefresher.command;

import net.coding.li709.materialrefresher.manage.BoxSpawnManager;
import net.coding.li709.materialrefresher.model.SpawnLoc;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;


/**
 * 添加生成宝箱的地点
 */
public class TestCommand implements CommandExecutor {

    @Override
    public CommandResult execute(CommandSource src, CommandContext args){
        if(src instanceof Player) {
            Player player = (Player) src;
            String locName = args.<String>getOne("locName").get();
            if (BoxSpawnManager.isSpawnLoc(locName)){
                SpawnLoc spawnLoc = BoxSpawnManager.getSpawnLoc(locName);
                spawnLoc.spawn();
                player.sendMessage(Text.of("使用生成点生成成功"));
            }else{
                player.sendMessage(Text.of("找不到生成点"));
            }
        }
        return CommandResult.success();
    }
}